import axios from '../utils/request';

function getCode (sid) {
  // let result = ''
  // try {
  //   result = await axios.get('/public/getCaptcha')
  //   if (result.status === 200) {
  //     return result.data
  //   }
  // } catch (e) {
  //   console.log(e)
  // }
  return axios.get('/public/getCaptcha', {
    params: {
      sid: sid
    }
  });
}

function sendEmail (option) {
  // try {
  //   const result = await axios.post('/login/forget', {...option})
  //   console.log(result)
  //   if (result.status === 200) {
  //     return result.data
  //   }
  // } catch (e) {
  //   console.log(e)
  // }
  return axios.post('/login/forget', { ...option });
}

function loginSubmit (data) {
  return axios.post('/login/auth', data);
}

function regSubmit (data) {
  return axios.post('/login/reg', data);
}

export {
  getCode,
  sendEmail,
  loginSubmit,
  regSubmit
};
